package com.xujl.fastlib.utils;

import java.util.List;
import java.util.Map;

public class CollectionsUtils {
    public static boolean isNotEmpty (List list) {
        return list != null && list.size() != 0;
    }

    public static boolean isEmpty (List list) {
        return list == null || list.size() == 0;
    }

    public static boolean isEmpty (Object[] list) {
        return list == null || list.length == 0;
    }

    public static boolean isNotEmpty (Map map) {
        return map != null && map.size() != 0;
    }

    public static boolean isEmpty (Map map) {
        return map == null || map.size() == 0;
    }

    public static <T> void addAll (List<T> source, List<T> target) {
        if (source == null || target == null) {
            return;
        }
        source.addAll(target);
    }

    public static int length (String[] list) {
        if (isEmpty(list)) {
            return 0;
        }
        return list.length;
    }
    public static int size (List list) {
        if (isEmpty(list)) {
            return 0;
        }
        return list.size();
    }
}
